package com.blb.day19_shiro.service.impl;

import com.blb.day19_shiro.entity.User;
import com.blb.day19_shiro.service.IUserService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class UserServiceImpl implements IUserService {

    //模拟数据库的用户
    private List<User> users = new ArrayList<>();

    {
        users.add(new User("user-1","fdeb53f302a8e73906b42d076cb4c20d","张三"));
        users.add(new User("user-2","bbdae287bc217149d90d8b0a4655bfe6","张小三"));
        users.add(new User("user-3","932e9626e97e22a5eb186af70ea68a72","张大三"));
        users.add(new User("admin","60d1225991bd2d1428b8916de60222fa","张三三"));
    }

    @Override
    public User findUserByUsername(String username) {
        for(User user : users){
            if(username.equals(user.getUsername())){
                return user;
            }
        }
        return null;
    }
}
